<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/BasicTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Rewired Documentation | Players</title>
<!-- InstanceEndEditable -->
<!-- InstanceParam name="isRoot" type="boolean" value="false" -->
<!-- InstanceParam name="wide" type="boolean" value="false" -->
<link href="files/css/styles.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="icon" type="image/x-icon" href="/projects/rewired/files/images/favicon.ico?v=1" />
<!-- Apple Icons -->
<!-- For iPad with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="files/images/favicon_152x152.png?v=1">
<!-- For iPad with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="files/images/favicon_144x144.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="files/images/favicon_120x120.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="files/images/favicon_114x114.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="files/images/favicon_76x76.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="files/images/favicon_72x72.png?v=1">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="files/images/favicon_57x57.png?v=1">
</head>

<body>


<div class="container">

    <div class="google-search-bar">
        <script>
          (function() {
            var cx = '007961148920562332911:oocvtwz5jce';
            var gcse = document.createElement('script');
            gcse.type = 'text/javascript';
            gcse.async = true;
            gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(gcse, s);
          })();
        </script>
        <gcse:search></gcse:search>
    </div>

  <div class="content">
	
	
	 
    <div class="page-body">
	
    
         
	    
      	<div class="sidebar-nav">
	        <h4><a href="Documentation.html">Documentation</a></h4>
	        <ul>
	          <li><a href="Overview.html">Overview</a></li>
	          <li><a href="ReleaseNotes.txt">Release Notes</a></li>
          </ul>
	        <strong>Essentials:</strong>
            <ol>
              <li><a href="Installation.html">Installation</a></li>
              <li><a href="QuickStart.html">Quick Start</a></li>
              <li><a href="BasicUsage.html">Basic Usage</a></li>
              <li><a href="Deployment.html">Deployment</a></li>
              <li><a href="BestPractices.html">Best Practices</a></li>
              <li><a href="RewiredEditor.html">Rewired Editor</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs/api-reference" target="_blank">API Reference</a></li>
            </ol>
            <strong>Concepts:</strong>
            <ul>
              <li><a href="InputManager.html">Input Manager</a></li>
              <li><a href="Players.html">Players</a></li>
              <li><a href="Actions.html">Actions</a></li>
              <li><a href="InputBehaviors.html">Input Behaviors</a></li>
              <li><a href="Controllers.html">Controllers</a></li>
              <li><a href="ControllerMaps.html">Controller Maps</a></li>
              <li><a href="ControllerTemplates.html">Controller Templates</a></li>
              <li><a href="MapCategories.html">Map Categories</a></li>
              <li><a href="Layouts.html">Layouts</a></li>
              <li><a href="LayoutManager.html">Layout Manager</a></li>
              <li><a href="MapEnabler.html">Map Enabler</a></li>
              <li><a href="CustomControllers.html">Custom Controllers</a></li>
            </ul>
            <strong>Extras:</strong>
            <ul>
              <li><a href="ControlMapper.html" title="Control Mapper">Control Mapper</a></li>
	          <li><a href="TouchControls.html" title="Touch Controls">Touch Controls</a></li>
              <li><a href="RewiredStandaloneInputModule.html">Rewired Standalone Input Module</a></li>
	          <li><a href="UnityInputOverride.html" title="Unity Input Override">Unity Input Override</a></li>
            </ul>
            <strong>Misc:</strong>
            <ul>
	          <li><a href="ComponentControls.html" title="Component Controls">Component Controls</a></li>
	          <li><a href="PlayerControllers.html" title="Player Controllers">Player Controllers</a></li>
	          <li><a href="InputMapper.html" title="Input Mapper">Input Mapper</a></li>
	          <li><a href="UserDataStore.html" title="User Data Store">User Data Store</a></li>
            </ul>
            <strong>How To's:</strong>
            <ul>
            	<li><a href="HowTos.html">See all topics...</a></li>
            </ul>
            <strong>Help:</strong>
            <ul>
              <li><a href="SupportedControllers.html" title="Supported Controllers">Supported Controllers</a></li>
              <li><a href="Overview.html#tested-platforms" title="Tested Platforms">Tested Platforms</a></li>
              <li><a href="Troubleshooting.html" title="Troubleshooting">Troubleshooting</a></li>
              <li><a href="KnownIssues.html">Known Issues</a></li>
              <li><a href="SpecialPlatformSupport.html" title="Special Platform Support">Special Platform Support</a></li>
	          <li><a href="Examples.html" title="Examples">Examples</a></li>
              <li><a href="Integration.html">Integrations</a></li>
	          <li><a href="Updating.html" title="Updating Rewired">Updating Rewired</a></li>
            </ul>
            <strong>FAQ</strong>
            <ul>
            	<li><a href="FAQ.html">See all topics...</a></li>
            </ul>
            <strong>Unity Help:</strong>
            <ul>
              <li><a href="https://docs.unity3d.com/Manual/" target="_blank">Unity Manual</a></li>
              <li><a href="https://docs.unity3d.com/ScriptReference/" target="_blank">Unity Script Reference</a></li>
              <li><a href="https://unity3d.com/learn/tutorials/modules" target="_blank">Unity Tutorials</a></li>
            </ul>
            <strong>Links:</strong>
            <ul>
              <li><a href="https://guavaman.com/projects/rewired">Rewired Website</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs">Web Documentation</a></li>
            </ul>
        </div>
        
    
    	<div class="main-body">
	        <div class="logo"><a href="https://guavaman.com/projects/rewired" title="Rewired"><img src="files/images/rewired-logo.png" width="173" height="139" alt="Rewired" /></a></div>
                     
            <h1>
            <!-- InstanceBeginEditable name="PageHeader" -->Players
      <!-- InstanceEndEditable -->
            </h1>
            
			<!-- InstanceBeginEditable name="MainBody" -->

    <p>Rewired features a player-centric input system. This means that generally all input is handled through the Player and not the controllers. You simply call <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_Player_GetAxis.htm">player.GetAxis</a>, <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_Player_GetButton.htm">player.GetButton</a>, etc. or register to receive input events with <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_Player_AddInputEventDelegate.htm">player.AddInputEventDelegate</a> to get access to all input regardless of the input sources. For example, you may need to respond to input from the keyboard, mouse, any number of joysticks, and any number of <a href="CustomControllers.html">Custom Controllers</a>. This is handled simply by assigning the controllers and the appropriate maps to the Player and then getting the input directly from the Player. The input you receive from the Player is a combination of input received from all the assigned controllers. Additionally,  joysticks can (optionally) be <a href="RewiredEditor.html#Settings">intelligently auto-assigned</a> to Players on connect and disconnect, so you don't have to worry about what controllers each Player owns. Instead, you simply get input for the specific Action you're looking for and Rewired handles the rest.</p>
    <p>It may help to think of a Player as a &quot;controller container&quot;. In other words, the Player can contain any number of controllers and controller maps. When you get input from the Player, you're really getting input from any controller owned by the Player that has an enabled Action -&gt; Element mapping.</p>
    <p>&nbsp;</p>
    <p><img src="files/images/input-mapping-diagram-3.png" alt="Player Input Diagram" /></p>
    <p>&nbsp;</p>

      <p><strong>Creating / Editing Players</strong></p>
      <p>Players are created at runtime by the Input Manager in the scene. You must define Players in the Rewired Editor in order for them to be created at runtime.</p>
      <p><strong>Accessing Players</strong></p>
      <p>The <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_PlayerHelper.htm">ReInput.players</a> property has methods to get access to a Player by id or name or to get a list of all Players. It's recommended you store a reference to the Player in  Awake and maintain that reference for the duration of the game. See <a href="HowTos.html#get-player">Getting a Player</a> for an example of how to get a Player.</p>

    <p><strong><a name="system-player" id="system-player"></a>System Player</strong></p>
<p>The System player exists as an option for handling system Actions such as Save, Load, etc. You can assign controllers and maps to the System player just as with any other player. Joysticks are never auto-assigned to the System player, but you can assign them manually to the System player through scripting.</p>
<p><strong>Getting Input</strong></p>
<p>In Rewired, you generally get input from the Player, not the controllers themselves. Please see <a href="HowTos.html#get-input">How To's - Getting Input</a> for more information.</p>
    <p><strong>Players and Controller Maps</strong></p>
    <p><a href="ControllerMaps.html">Controller Maps</a> are what associates controller elements to Actions. As Rewired is a player-centric input system, controller maps aren't stored in the controller, but rather in the Player. This has the benefit of allowing you to share controllers among as many Players as you want while each maintains its own separate set of Action mappings.</p>
    <p>The <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_Player.htm">Player</a> class contains many methods for getting, adding, and removing all types of controller maps. (Access these methods through the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_Player_ControllerHelper_MapHelper.htm">Player.controllers.maps</a> helper object.) Additionally, assignment conflict checking and saving/loading maps is handled through the Player class.</p>
    <p>Even if a controller is assigned to a Player, if no maps are assigned, no input will be possible. You should define starting maps for joysticks, the keyboard, and the mouse for each Player in the <a href="RewiredEditor.html">Rewired Editor</a>. You can also load and assign maps during runtime through scripting via the <a href="https://guavaman.com/projects/rewired/docs/api-reference/?topic=html/T_Rewired_Player.htm">Player</a> class. </p>
    <p><strong><a name="controllers" id="controllers"></a>Players and Controllers</strong></p>
    <p>A Player is essentially a container for controllers and Controller Maps. The Controller Maps contained in Player provide a means to associate Actions to controller elements (button, key, axis, etc.). There are some slight differences between how the different types of controllers are handled by the Player.</p>
    <p>Rewired currently has 4 types of Controller classes:</p>
    <ul>
      <li>Joystick (a device attached to the system that is not a keyboard or mouse.)</li>
      <li>Keyboard</li>
      <li>Mouse</li>
      <li>Custom Controller</li>
      </ul>
    <p><strong><a name="joysticks" id="joysticks"></a>Joysticks</strong></p>
    <p>Before a Player can return input for a Joystick, that joystick must first be assigned to the Player. The joystick must be added to the Player's list of joysticks before it can receive input from that device. A joystick may be assigned to multiple Players and shared if desired (this would be rare).</p>
    <p>By default, Rewired's Joystick Auto-Assignment system is enabled in the Rewired Input Manager. This ensures that each Player is assigned one joystick when it is attached to the system based on rules set in the <a href="RewiredEditor.html#settings">Rewired Input Manager - Settings page</a>. You may disable the auto-assignment system if you have special needs that are not covered by its options. <a href="HowTos.html#assigning-joysticks">See How To's - Assigning Joysticks to Players</a> for information on how to assign Joysticks manually.</p>
    <p>For input to be returned in a Player from a Joystick, all of the following must be true:</p>
    <ul>
      <li>The Joystick must be assigned to the Player.</li>
      <li>The Player must have at least one enabled Joystick Map applicable to that joystick.</li>
      <li>The Joystick Map must  bind at least one joystick element to an Action.</li>
      </ul>
    <p><strong>Do not be confused:</strong> The fact that a Player &quot;has a Joystick Map&quot; in the Rewired Input Manager is not the same thing as the joystick being assigned to that Player. Maps are entirely separate from joystick assignment and do not influence what joysticks (if any) will be assigned to a Player by the joystick auto-assignment system. Joystick assignment involves adding the Joystick class object to the Player. Once the Joystick is assigned, Rewired will load the Joystick Maps for that particular Joystick in the Player (if one or more applicable Joystick Maps were created and assigned to the Player in the Rewired Editor) and then the Joystick Maps will perform the function of mapping Actions to the elements on that Joystick. If a joystick is assigned to a Player but no matching Joystick Maps are found, that Joystick will not contribute any input in that Player.</p>
<p><strong><a name="keyboard" id="keyboard"></a>Keyboard</strong></p>
<p>In Rewired, the keyboard is a shared controller. Similar to Joysticks, the keyboard must also be assigned to the Player(s) before it will return any input. This can be set at start in the <a href="RewiredEditor.html#players">Rewired Input Manager - Players</a> page, or set via scripting using the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_Player_ControllerHelper_hasKeyboard.htm">player.controllers.hasKeyboard</a> property. By default, the keyboard is assigned to all Players on start unless disabled in the Rewired Input Manager.</p>
<p>Just like Joysticks, the keyboard  will only return input in a Player if the Player has at least one Keyboard Map that associates some Actions to keys.</p>
<p><strong><a name="mouse" id="mouse"></a>Mouse</strong></p>
<p>Similar to Joysticks, the mouse must also be assigned to the Player(s) before it will return any input. This can be set at start in the <a href="RewiredEditor.html#players">Rewired Input Manager - Players</a> page, or set via scripting using the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_Player_ControllerHelper_hasMouse.htm">player.controllers.hasMouse</a> property. The mouse may be shared by multiple Players if desired.</p>
<p>Just like Joysticks and the Keyboard, the mouse  will only return input in a Player if the Player has at least one Mouse Map that associates some Actions to mouse buttons and axes.</p>
<p><strong><a name="custom-controller" id="custom-controller"></a>Custom Controller</strong></p>
<p><a href="CustomControllers.html">Custom Controllers</a> are very similar to Joysticks in treatment except for the fact that they are never disconnected from the system and are always available. The same rules apply -- the Custom Controller must be assigned to a Player and have one or more valid Custom Controller Maps to return any input value.</p>
<p><strong>See Also</strong></p>
    <p><a href="https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_Player.htm">API Reference - Player</a></p>
    <div class="bottom-pager clearfix">
	    <a class="back-button" href="InputManager.html" title="Input Manager"><span class="button-img"></span>Input Manager</a>
    	<a class="forward-button" href="Actions.html" title="Actions"><span class="button-img"></span>Actions</a>
	</div>
<!-- InstanceEndEditable -->
        </div>
        
    </div>
  <div class="footer clearfix">
   	<p class="left">Copyright &copy;2014-2021 <a href="https://guavaman.com" title="Guavaman Enterprises">Guavaman Enterprises</a>. All rights reserved. No materials may be reproduced without permission.</p>
  	<p class="right"><a href="https://guavaman.com/projects/rewired" title="Return to Rewired Website">Return to Rewired Website</a></p>
  </div>
  <!-- end .content --></div>
  <!-- end .container --></div>
  
  
</body>
<!-- InstanceEnd --></html>
